package com.zhibang.controller;

import com.zhibang.entity.Administrator;
import com.zhibang.service.AdministratorService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

@Controller
@CrossOrigin("*")
public class AdministratorController {
    @Autowired
    AdministratorService administratorService;

    public @ResponseBody String  addAdministrator(@RequestBody Administrator administrator){
        Administrator administrator1=new Administrator();
        administrator1.setAid(administrator.getAid());
        administrator1.setApassworld(administrator.getApassworld());
        boolean i=administratorService.save(administrator1);
        return i?"添加成功":"添加失败";
    }
    public @ResponseBody List<Administrator> findAll(){
        return administratorService.list();
    }
}
